<%@page import="factory.DaoFactory"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.io.File"%>
<%@page import="basepath.BasePath"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>考前操作-修改考试信息</title>
<script type="text/javascript">
function check(){
	if(document.getElementById("upfile").value()=="")
	{
		return false;
	}
	else{
		return true;
	}
	
}
</script>
</head>

<body>
	
	<%@include file="teacher_head.jsp"%>
	<div class="container">
		<div class="row">
			<div class="form-inline">
				<img src="../../resource/teacher.jpg" class="img-rounded imgstyle" />
				<h1>
					<strong>上机考试管理</strong>
				</h1>
			</div>
		</div>
	</div>
	<hr>
	<div class="container divcontainerstyle">
		<h2>
			编辑考试信息 id=<%=session.getAttribute("examid")%></h2>
		<form action="../../servlet_exammodify_teacher" method="post">
			<div class="form-inline">
				<label>考试名称:</label> <input
					value="<%=session.getAttribute("examname")%>"
					name="examname_modify" type="text" placeholder="考试名称*"
					class="form-control"> <label>考试时间:</label> <input
					type="datetime-local"
					value="<%=session.getAttribute("starttime")%>"
					name="starttime_modify" placeholder="考试时间*" class="form-control">
				<input type="checkbox" name="autostart"> <small>自动开始</small>
				<input name="examid" value="<%=session.getAttribute("id")%>"
					style="display: none" readonly="readonly">
				<button name="autostart_modify" class="btn btn-primary btn-sm"
					style="display: inline;">修改</button>
			</div>
		</form>
		<hr>
	</div>
	<br>
	<div class="container divcontainerstyle">
		<h2>上传试卷</h2>





		<form
			action="../../servlet_uploadtestpaper_teacher?examname=<%=session.getAttribute("examname")%>"
			method="post" enctype="multipart/form-data">

			<div class="form-inline">

				<button type="button"  onclick="path.click()"
					class="btn btn-info glyphicon glyphicon-folder-open">浏览</button>

				<input type="text" name="upfile" id="upfile" class="form-control"
					placeholder="未选择文件" readonly="readonly"> <input type="file"
					id="path" name="upload" style="display: none"
					onchange="upfile.value=this.value">
				<button type="submit" id="but1"
					class="btn btn-info glyphicon glyphicon-cloud-upload"
					style="display: inline;">上传</button>
			</div>
		</form>

		<table class="table table-striped table-bordered table-hover">
			<thead>
				<tr>
					<td>已上传文件</td>
					<td>文件大小</td>
					<td>上传时间</td>
				</tr>
			</thead>
			<tbody>


				<%
					BasePath b = new BasePath();
					if (b != null) {
						String path = b.getRealBasePath(request) + "data/testpaper/" + request.getParameter("examcreator") + "/"
								+ request.getParameter("examname") + "/";
						File dir = new File(path);
						if (dir != null) {
							File[] files = dir.listFiles();
							if (files != null) {
								for (int i = 0; i < files.length; i++) {
				%>
				<tr>
					<td><%=files[i].getName()%></td>
					<td><%=files[i].length() / 8%>B</td>
					<td><%=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(files[i].lastModified())%></td>
				</tr>
				<%
					}
							}
						}
					}
				%>



			</tbody>

		</table>






	</div>
	<br>
	<div class="container divcontainerstyle">
		<h2>导入学生名单</h2>
		<span>ps:第一列:studentnumber 第二列:studentname 第三列:classroom</span>
		<p>目前设定参加此次考试的学生人数：<%= DaoFactory.getTeacherDaoInstance().getstudentcount(request.getParameter("id")) %></p>

		<form action="../../servlet_uploadstudentlist_teacher" method="post"
			enctype="multipart/form-data">

			<div class="form-inline">

				<button type="button" onclick="path.click()"
					class="btn btn-info glyphicon glyphicon-folder-open">浏览</button>

				<input type="text" name="upfile" id="upfile" class="form-control"
					placeholder="未选择文件" readonly="readonly"> <input type="file"
					id="path" name="upload" style="display: none"
					onchange="upfile.value=this.value">
				<button type="submit"
					class="btn btn-info glyphicon glyphicon-cloud-upload"
					style="display: inline;">导入</button>
			</div>
		</form>

	</div>

	<hr>
	<div class="container divcontainerstyle">
		<h2>开启考试</h2>
		<p>尚未开启考试</p>
		<a href="../../servlet_startexam_teacher"
			class="btn btn-primary btn-lg glyphicon glyphicon-off"> 开启</a>
	</div>
</body>
</html>